package web.Servlet;

import domain.student;
import domain.studentgroup;
import service.Serviceimpl.SudentServiceImpl;
import service.Serviceimpl.studentGroupServiceImpl;
import service.studentGroupService;
import service.studentService;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.sql.SQLException;
import java.util.List;

/*/admin.do*/
public class findAllServlet extends HttpServlet {

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doPost(req,resp);
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        /*接受前台传输过来的值*/
        String fzid = req.getParameter("fzid");
        String studentname = req.getParameter("studentname");

        System.out.println(studentname);
        if(fzid!=null&&fzid!=""){
            Integer integer = Integer.valueOf(fzid);
        }
        studentService studentservice = new SudentServiceImpl();
        studentGroupService studentGroupService=new studentGroupServiceImpl();
        try {
            /*查询所有学生*/
            List<student> all = studentservice.findAll(fzid,studentname);
            /*查询所有分组*/
            List<studentgroup> all1 = studentGroupService.findAll();
            /*将数据放到我的request对象中*/
            req.setAttribute("list",all);
            req.setAttribute("studentname",studentname);
            /*分组信息*/
            req.setAttribute("studentG",all1);
            req.setAttribute("fzid",fzid);
            req.getRequestDispatcher("3_17/admin.jsp").forward(req,resp);
        } catch (SQLException e) {
            e.printStackTrace();
        }
    }
}
